package com.ruoyi.web.controller.app;

import com.ruoyi.order.domain.app.Vo.CategoryResultVo;
import com.ruoyi.order.service.ICategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 陈焕然
 * @version 1.0
 */
@Controller
@RequestMapping("/app")

public class CategoryAppController {
    @Autowired
    private ICategoryService categoryService;

    /**
     * 获取商品目录 一级二级分类
     * @return
     */
    @RequestMapping("/getCategoryList")
    @ResponseBody
    public  List<CategoryResultVo> getCategoryList(){
        List<CategoryResultVo> result = new ArrayList<>();
        List<CategoryResultVo> list= categoryService.getCategoryList();
        if(list!=null&&list.size()>0){
            result = list;
        }
        return result;
    }

    /**
     * 根据商品一级目录id返回对应的分类目录 获取二级三级
     * @return
     */
    @RequestMapping("/categoryList/categoryInfo")
    @ResponseBody
    public  List<CategoryResultVo> getcategoryInfo(Integer parentId){
        List<CategoryResultVo> result = new ArrayList<>();
        List<CategoryResultVo> list=  categoryService.getCategoryInfo(parentId);
        if(list!=null&&list.size()>0){
            result = list;
        }
        return result;
    }
}
